﻿Public Class SaisieNouveauVaccin_CTRL

    Private _EDM As AniFormEntities
    Private _vaccinEnregistre As Vaccins

    Public Sub New(ByVal edm As AniFormEntities)
        _EDM = edm
        _vaccinEnregistre = Nothing
    End Sub

    Public ReadOnly Property getVaccinEnregistre() As Vaccins
        Get
            Return _vaccinEnregistre
        End Get
    End Property

    Public Function EnregistrerVaccin(ByVal nomVaccin As String, ByVal periodeValidite As Integer) As Vaccins
        Dim vaccin As New Vaccins
        With vaccin
            .CodeVaccin = Guid.NewGuid
            .NomVaccin = nomVaccin
            .PeriodeValidite = periodeValidite
            .QuantiteStock = 0
            .Archive = False
        End With
        _vaccinEnregistre = vaccin
        _EDM.AddToVaccins(vaccin)
        _EDM.SaveChanges(True)
        Return vaccin
    End Function
End Class
